Skip to main content

PutBucketLogging

Description

Bucket owner can enable access logging for Bucket. After this function is enabled, OSS automatically records the details of requests to access this bucket, and writes the access log as an object to the bucket specified by the user in hours according to the rules specified by the user.

Request Method

POST

Request Path

/apsara/route/OneRouter/PutBucketLogging

Request Parameters Common Parameters

NameLocationTypeRequiredSample valueDescription
BucketLoggingStatusBODYcontainerYesnot involvedcontainer for accessing log status information.
TargetPrefixBODYstringNoMyLog-specifies the final saved access log file prefix.
regionIdBODYstringYesNo sample value for this parameter.region id
TargetBucketBODYstringNodoc-logspecifies the bucket on which access logs are stored.
versionBODYstringNo2016-01-01version of api
LoggingEnabledBODYcontainerNonot involvedcontainer for accessing log information. This element is needed when it is turned on and not when it is turned off.

Return data

NameTypeSample valueDescription
LoggingFlagtrueno demo valuewhether the access log function is enabled.
Remote IP119.140.142.11no demo valuerequest initiated IP address (Proxy proxy or user firewall may block this field).
Refererhttp://www.aliyun.com/product/ossno demo valuethe requested HTTP Referer.
User-Agentcurl/7.15.5no demo valueHTTP User-Agent header.
ObjectSize5576no demo valueObject size.
Sync Request-no demo valueis it a CDN back-to-source request; if it is not -.
Time[02/may/2012:00:00:04 +0800]no demo valueThe time when OSS received the request.
Request-URI"get /aliyun-logo.png http/1.1"no demo valueURI (including query-string) requested by the user.
Request ID505b01695037c2af032593a4no demo valueUUID used to uniquely identify the request.
Operationgetobjectno demo valuerequest type.
RequestTime (ms)71no demo valuethe time (in milliseconds) to complete this request.
Server Cost Time (ms)17no demo valueThe time (milliseconds) taken by the OSS server to process this request.
Error Codenosuchbucketno demo valueThe error code returned by OSS.
Request Length302no demo valueThe length of the user request (Byte).
SentBytes5576no demo valueTraffic downloaded by users from OSS.
Bucketoss-exampleno demo valuethe name of the bucket to be accessed.
UserID1657136103983691no demo valueBucket owner ID.
Requester Aliyun ID1657136103983691no demo valueAliyun ID of the requester; - when accessing anonymously.
HTTP Status200no demo valueHTTP status code returned by OSS.
HostNameoss-example.regionid.example.comno demo valuerequest to access the domain name.
Key/aliyun-logo.pngno demo valueKey requested by the user.
Reserved-no demo valuereserved fields.
Delta DataSize280no demo valueBucket size change; if there is no change to -.

Example

Successful Response example

{
"LoggingFlag":"no demo value",
"Remote IP":"no demo value",
"Referer":"no demo value",
"User-Agent":"no demo value",
"ObjectSize":"no demo value",
"Sync Request":"no demo value",
"Time":"no demo value",
"Request-URI":"no demo value",
"Request ID":"no demo value",
"Operation":"no demo value",
"RequestTime (ms)":"no demo value",
"Server Cost Time (ms)":"no demo value",
"Error Code":"no demo value",
"Request Length":"no demo value",
"SentBytes":"no demo value",
"Bucket":"no demo value",
"UserID":"no demo value",
"Requester Aliyun ID":"no demo value",
"HTTP Status":"no demo value",
"HostName":"no demo value",
"Key":"no demo value",
"Reserved":"no demo value",
"Delta DataSize":"no demo value"
}

Failed Response example

{
"errorSample":
{
"resultCode":-1,
"resultMsg":"system error",
"result":null
}

}